/**
 * 2008 Sylvain Dudoit (All rights reserved)
 *
 * $Id$
 */
package org.bankabeule.impl;

import java.util.Collection;

import org.bankabeule.Account;
import org.bankabeule.AccountTypeEnum;
import org.bankabeule.BankabeulePackage;
import org.bankabeule.MoneyEnum;
import org.bankabeule.Operation;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Account</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.bankabeule.impl.AccountImpl#getId <em>Id</em>}</li>
 *   <li>{@link org.bankabeule.impl.AccountImpl#getBankid <em>Bankid</em>}</li>
 *   <li>{@link org.bankabeule.impl.AccountImpl#getBranchid <em>Branchid</em>}</li>
 *   <li>{@link org.bankabeule.impl.AccountImpl#getType <em>Type</em>}</li>
 *   <li>{@link org.bankabeule.impl.AccountImpl#getMoney <em>Money</em>}</li>
 *   <li>{@link org.bankabeule.impl.AccountImpl#getOperations <em>Operations</em>}</li>
 *   <li>{@link org.bankabeule.impl.AccountImpl#getInitValue <em>Init Value</em>}</li>
 *   <li>{@link org.bankabeule.impl.AccountImpl#getValue <em>Value</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AccountImpl extends ElementImpl implements Account {
	/**
	 * The default value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected static final String ID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected String id = ID_EDEFAULT;

	/**
	 * The default value of the '{@link #getBankid() <em>Bankid</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBankid()
	 * @generated
	 * @ordered
	 */
	protected static final String BANKID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getBankid() <em>Bankid</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBankid()
	 * @generated
	 * @ordered
	 */
	protected String bankid = BANKID_EDEFAULT;

	/**
	 * The default value of the '{@link #getBranchid() <em>Branchid</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBranchid()
	 * @generated
	 * @ordered
	 */
	protected static final String BRANCHID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getBranchid() <em>Branchid</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBranchid()
	 * @generated
	 * @ordered
	 */
	protected String branchid = BRANCHID_EDEFAULT;

	/**
	 * The default value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected static final AccountTypeEnum TYPE_EDEFAULT = AccountTypeEnum.NONE;

	/**
	 * The cached value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected AccountTypeEnum type = TYPE_EDEFAULT;

	/**
	 * The default value of the '{@link #getMoney() <em>Money</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMoney()
	 * @generated
	 * @ordered
	 */
	protected static final MoneyEnum MONEY_EDEFAULT = MoneyEnum.NONE;

	/**
	 * The cached value of the '{@link #getMoney() <em>Money</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMoney()
	 * @generated
	 * @ordered
	 */
	protected MoneyEnum money = MONEY_EDEFAULT;

	/**
	 * The cached value of the '{@link #getOperations() <em>Operations</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOperations()
	 * @generated
	 * @ordered
	 */
	protected EList<Operation> operations;

	/**
	 * The default value of the '{@link #getInitValue() <em>Init Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInitValue()
	 * @generated
	 * @ordered
	 */
	protected static final double INIT_VALUE_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getInitValue() <em>Init Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInitValue()
	 * @generated
	 * @ordered
	 */
	protected double initValue = INIT_VALUE_EDEFAULT;

	/**
	 * The default value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected static final double VALUE_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected double value = VALUE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AccountImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BankabeulePackage.Literals.ACCOUNT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getId() {
		return id;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setId(String newId) {
		String oldId = id;
		id = newId;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					BankabeulePackage.ACCOUNT__ID, oldId, id));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getBankid() {
		return bankid;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBankid(String newBankid) {
		String oldBankid = bankid;
		bankid = newBankid;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					BankabeulePackage.ACCOUNT__BANKID, oldBankid, bankid));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getBranchid() {
		return branchid;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBranchid(String newBranchid) {
		String oldBranchid = branchid;
		branchid = newBranchid;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					BankabeulePackage.ACCOUNT__BRANCHID, oldBranchid, branchid));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AccountTypeEnum getType() {
		return type;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setType(AccountTypeEnum newType) {
		AccountTypeEnum oldType = type;
		type = newType == null ? TYPE_EDEFAULT : newType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					BankabeulePackage.ACCOUNT__TYPE, oldType, type));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MoneyEnum getMoney() {
		return money;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMoney(MoneyEnum newMoney) {
		MoneyEnum oldMoney = money;
		money = newMoney == null ? MONEY_EDEFAULT : newMoney;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					BankabeulePackage.ACCOUNT__MONEY, oldMoney, money));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Operation> getOperations() {
		if (operations == null) {
			operations = new EObjectContainmentEList<Operation>(
					Operation.class, this,
					BankabeulePackage.ACCOUNT__OPERATIONS);
		}
		return operations;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getInitValue() {
		return initValue;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setInitValue(double newInitValue) {
		double oldInitValue = initValue;
		initValue = newInitValue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					BankabeulePackage.ACCOUNT__INIT_VALUE, oldInitValue,
					initValue));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getValue() {
		return value;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setValue(double newValue) {
		double oldValue = value;
		value = newValue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					BankabeulePackage.ACCOUNT__VALUE, oldValue, value));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
		case BankabeulePackage.ACCOUNT__OPERATIONS:
			return ((InternalEList<?>) getOperations()).basicRemove(otherEnd,
					msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
		case BankabeulePackage.ACCOUNT__ID:
			return getId();
		case BankabeulePackage.ACCOUNT__BANKID:
			return getBankid();
		case BankabeulePackage.ACCOUNT__BRANCHID:
			return getBranchid();
		case BankabeulePackage.ACCOUNT__TYPE:
			return getType();
		case BankabeulePackage.ACCOUNT__MONEY:
			return getMoney();
		case BankabeulePackage.ACCOUNT__OPERATIONS:
			return getOperations();
		case BankabeulePackage.ACCOUNT__INIT_VALUE:
			return new Double(getInitValue());
		case BankabeulePackage.ACCOUNT__VALUE:
			return new Double(getValue());
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case BankabeulePackage.ACCOUNT__ID:
			setId((String) newValue);
			return;
		case BankabeulePackage.ACCOUNT__BANKID:
			setBankid((String) newValue);
			return;
		case BankabeulePackage.ACCOUNT__BRANCHID:
			setBranchid((String) newValue);
			return;
		case BankabeulePackage.ACCOUNT__TYPE:
			setType((AccountTypeEnum) newValue);
			return;
		case BankabeulePackage.ACCOUNT__MONEY:
			setMoney((MoneyEnum) newValue);
			return;
		case BankabeulePackage.ACCOUNT__OPERATIONS:
			getOperations().clear();
			getOperations().addAll((Collection<? extends Operation>) newValue);
			return;
		case BankabeulePackage.ACCOUNT__INIT_VALUE:
			setInitValue(((Double) newValue).doubleValue());
			return;
		case BankabeulePackage.ACCOUNT__VALUE:
			setValue(((Double) newValue).doubleValue());
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
		case BankabeulePackage.ACCOUNT__ID:
			setId(ID_EDEFAULT);
			return;
		case BankabeulePackage.ACCOUNT__BANKID:
			setBankid(BANKID_EDEFAULT);
			return;
		case BankabeulePackage.ACCOUNT__BRANCHID:
			setBranchid(BRANCHID_EDEFAULT);
			return;
		case BankabeulePackage.ACCOUNT__TYPE:
			setType(TYPE_EDEFAULT);
			return;
		case BankabeulePackage.ACCOUNT__MONEY:
			setMoney(MONEY_EDEFAULT);
			return;
		case BankabeulePackage.ACCOUNT__OPERATIONS:
			getOperations().clear();
			return;
		case BankabeulePackage.ACCOUNT__INIT_VALUE:
			setInitValue(INIT_VALUE_EDEFAULT);
			return;
		case BankabeulePackage.ACCOUNT__VALUE:
			setValue(VALUE_EDEFAULT);
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case BankabeulePackage.ACCOUNT__ID:
			return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
		case BankabeulePackage.ACCOUNT__BANKID:
			return BANKID_EDEFAULT == null ? bankid != null : !BANKID_EDEFAULT
					.equals(bankid);
		case BankabeulePackage.ACCOUNT__BRANCHID:
			return BRANCHID_EDEFAULT == null ? branchid != null
					: !BRANCHID_EDEFAULT.equals(branchid);
		case BankabeulePackage.ACCOUNT__TYPE:
			return type != TYPE_EDEFAULT;
		case BankabeulePackage.ACCOUNT__MONEY:
			return money != MONEY_EDEFAULT;
		case BankabeulePackage.ACCOUNT__OPERATIONS:
			return operations != null && !operations.isEmpty();
		case BankabeulePackage.ACCOUNT__INIT_VALUE:
			return initValue != INIT_VALUE_EDEFAULT;
		case BankabeulePackage.ACCOUNT__VALUE:
			return value != VALUE_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy())
			return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (id: ");
		result.append(id);
		result.append(", bankid: ");
		result.append(bankid);
		result.append(", branchid: ");
		result.append(branchid);
		result.append(", type: ");
		result.append(type);
		result.append(", money: ");
		result.append(money);
		result.append(", initValue: ");
		result.append(initValue);
		result.append(", value: ");
		result.append(value);
		result.append(')');
		return result.toString();
	}

} //AccountImpl
